package com.example.sourcesprng;

import com.example.sourcesprng._initialization.InitializationService;
import com.example.sourcesprng.instantiation.InitBeforeService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.PropertySource;


@SpringBootApplication
public class SourcesprngApplication {

    public static void main(String[] args) {
        SpringApplication.run(SourcesprngApplication.class, args);
//        ConfigurableApplicationContext context = new SpringApplicationBuilder(SourcesprngApplication.class).run(args); // 运行应用，传入命令行参数

        // 现在可以访问和操作 bean 了
        // 例如，获取某个 bean
//        Object myObject01 = context.getBean("myFactoryBean");
//        Object myObject02 = context.getBean("myObject");
////        Object bean = context.getBean("&myFactoryBean");
//
//        MyObject bean = context.getBean(MyObject.class);
//
////        UseFactoryBean useFactoryBean = (UseFactoryBean) context.getBean("useFactoryBean");
////        useFactoryBean.userFactoryBean();
////        System.out.println("结束");
//
//        Student bean1 = context.getBean(Student.class);
//        bean1.say();

        // 实例化前
//        InitBeforeService bean = context.getBean(InitBeforeService.class);
//        System.out.println(bean);
//        bean.say();
//        bean = context.getBean(InitBeforeService.class);
//        System.out.println(bean);

        // 初始化
//        InitializationService bean = context.getBean(InitializationService.class);
//        System.out.println(bean.getName());
//        System.out.println(bean.getAge());
//
//
//        System.out.println("结束");
    }

}
